package erfgame.frontend.desktop.view.terrain.iso;

import java.util.List;

import erfgame.core.Filter;
import erfgame.core.entity.Entity;
import erfgame.core.graphics.renderer.chain.RendererChain;

public class EntityInSelectionFilter implements Filter<Entity> {
	
	private EntitySelection selection;
	
	public EntityInSelectionFilter( EntitySelection selection ) {
		this.selection = selection;
	}

	public boolean accept(Entity o) {
		List<RendererChain> renderers = selection.getSelected();
		if( renderers != null ) {
			for( int i=renderers.size(); i>0; ) {
				i--;
				RendererChain renderer = renderers.get(i);
				if( renderer.getHead().getEntity() == o ) {
					return true;
				}
			}
		}
		return false;
	}
}
